
// 分销等级表头组件
import React, { useState } from 'react';
import {Button, Form, Input, Select} from "antd";
import LevleAddData from "@/pages/distribution/DistributionLevel/components/LevleAddData";



const LevelTitle = (props) => {
  const {actionRef,searchValues,setSearchValue} = props
  const [searchObj,setSearchObj] = useState({})


  const onFormLayoutChange =async ( _,allValues) => {
    console.log(allValues);
    const {is_show,position} = allValues

    if(is_show && position){
      setSearchObj({is_show,position})
    }else if(is_show){
      setSearchObj({is_show})
    }else if(position){
      setSearchObj({position})
    }else{
      setSearchObj({})
    }
  };

  const searchSubmit = async ()=>{
    setSearchValue(searchObj)
    // console.log(searchValues);
  }

  return (
    <div style={{background:'#fff',padding:'20px 25px'}}>
      <div style={{display:'inline-block',width:'50%',marginBottom:'-35px',marginRight:'10px'}}>
        <Form
          layout="horizontal"
          onValuesChange={onFormLayoutChange}
        >
          <Form.Item  name='is_show' label="是否显示"  style={{width:'45%',float:'left',marginRight:'10px'}}>
            <Select placeholder='请选择' defaultValue='全部'>
              <Select.Option value={undefined}>全部</Select.Option>
              <Select.Option value="1">显示</Select.Option>
              <Select.Option value="0">不显示</Select.Option>
            </Select>
          </Form.Item>
          <Form.Item name='position' label="等级名称"  style={{width:'50%',float:'left'}}>
            <Input />
          </Form.Item>
        </Form>
      </div>
      <Button onClick={searchSubmit} type="primary" style={{marginRight:'10px'}}>
        搜索
      </Button>

      {/*添加数据组件*/}
      <LevleAddData actionRef={actionRef}/>
    </div>
  );
};

export default LevelTitle;
